package com.aaa.service.impl;

import com.aaa.commen.domain.ReceiveInfo;
import com.aaa.commen.domain.UserLogin;
import com.aaa.commen.entity.Result;
import com.aaa.mapper.OperateLogMapper;
import com.aaa.mapper.ReceiveInfoMapper;
import com.aaa.mapper.UserDeptMapper;
import com.aaa.service.IReceiveInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @PackageName: com.aaa.service.impl
 * @ClassName: ReceiveInfoServiceImpl
 * @Description:
 * @author: 王嘉威
 * @Date: 2021/1/19 21:38
 */
@Service
public class ReceiveInfoServiceImpl extends ServiceImpl<ReceiveInfoMapper, ReceiveInfo> implements IReceiveInfoService {
    @Autowired
    private ReceiveInfoMapper receiveInfoMapper;

    /**
     * 查询某个合同所有已收取详细租金信息
     */
    public Result queryReceiveInfo(String contractId) {
        List<ReceiveInfo> receiveInfos = receiveInfoMapper.queryReceiveInfo(contractId);
        return Result.success(receiveInfos);
    }

    /**
     * 根据发票号删除目标合同的某条租金信息
     */
    @Override
    public Result deleteReceiveInfo(int invoiceId) {
        int i = receiveInfoMapper.deleteReceiveInfo(invoiceId);
        if (i > 0) {
            return Result.success("已删除");
        }
        return Result.error("删除失败");
    }

    /**
     * 修改某合同的租金收取信息
     */
    @Override
    public Result updateReceiveInfo(ReceiveInfo receiveInfo) {
        int i = receiveInfoMapper.updateReceiveInfo(receiveInfo);
        System.out.println(i);
        if (i > 0) {
            return Result.success("修改成功");
        }
        return Result.error("修改失败");
    }
}
